home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 2.5 KB | 98 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPostEx.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFound.hpp"
-
- #ifndef FWPOSTEX_H
- #include "FWPostEx.h"
- #endif
-
- #ifndef FWPRIMEM_H
- #include "FWPriMem.h"
- #endif
-
- #ifndef FWPRIDEB_H
- #include "FWPriDeb.h"
- #endif
-
- #ifndef FWEXCDEF_H
- #include "FWExcDef.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment BEL
- #endif
-
-
- FW_SPrivPostedExceptionGlobals FW_CPostedException::gGlobals;
-
-
- //----------------------------------------------------------------------------------------
- // FW_CPostedException::GetPostedExceptionGlobals
- //----------------------------------------------------------------------------------------
-
- FW_SPrivPostedExceptionGlobals& FW_CPostedException::GetPostedExceptionGlobals()
- {
- // FW_SPrivPostedExceptionGlobals *globals = (FW_SPrivPostedExceptionGlobals*)
- // FW_CPrivTaskGlobals::GetTaskGlobals(kPostedExceptionGlobals);
- FW_SPrivPostedExceptionGlobals *globals = &gGlobals;
- if (globals->gInitialized == 0)
- Initialize(*globals);
- return *globals;
- }
-
- void FW_CPostedException::Initialize(FW_SPrivPostedExceptionGlobals& globals)
- {
- // globals.gMaxPostedSize = FW_CPrivExceptionRuntime::kDefaultExceptionBufferSize;
- globals.gMaxPostedSize = 1024; // [KVV]
-
- globals.gPostedException = (_FW_XException*)
- ::FW_PrimitiveAllocateBlock(globals.gMaxPostedSize);
- FW_PRIV_ASSERT(globals.gPostedException != 0);
-
- globals.gPending = 0;
-
- FW_PRIV_ASSERT(!globals.gInitialized);
- globals.gInitialized = 1;
- }
-
- void FW_CPostedException::Terminate()
- {
- FW_SPrivPostedExceptionGlobals& globals = GetPostedExceptionGlobals();
- FW_PRIV_ASSERT(globals.gInitialized);
- ::FW_PrimitiveFreeBlock(globals.gPostedException);
- globals.gInitialized = 0;
- }
-
- void FW_CPostedException::PostException(const _FW_XException& exception)
- {
- FW_SPrivPostedExceptionGlobals& globals = GetPostedExceptionGlobals();
- FW_PRIV_ASSERT(globals.gInitialized);
- if (!globals.gPending)
- {
- exception.Copy(globals.gPostedException, globals.gMaxPostedSize);
- globals.gPending = 1;
- }
- }
-
- void FW_CPostedException::ThrowPostedException()
- {
- FW_SPrivPostedExceptionGlobals& globals = GetPostedExceptionGlobals();
- FW_PRIV_ASSERT(globals.gInitialized);
- if (globals.gPending)
- {
- globals.gPending = 0;
- FW_THROW(*globals.gPostedException);
- }
- }
-